﻿#ifdef _DEBUG
#pragma comment(lib,"../include/MyDlld.lib")	//若Debug时无需进入dll程序，则不需要加载lib
#else
#pragma comment(lib,"../include/MyDll.lib")
#endif

#include "../include/Platform/Common.h"
#include "../include/IMyDll.h"
#include <iostream>
#include <memory>

int main()
{
	void* pMyDll = LOAD_LIB("../include/MyDlld.dll");	//可以从ini中加载指定的dll
	if (pMyDll != nullptr)
	{
		using PF = std::shared_ptr<IMyDll>*(*)();	//函数指针类型别名
		PF pf = (PF)FIND_FUNC(pMyDll,"GetObj");		//p指向dll中GetObj()
		std::shared_ptr<IMyDll> sptrMyDll = *pf();	//p是指针的指针，所以取值
		//调用成员函数
		sptrMyDll->setNumber(10);
		std::cout << sptrMyDll-> getNumber() << std::endl;
	}

	//注意释放（在合理的位置）
	CLOSE_LIB(pMyDll);
	pMyDll = nullptr;	//非new，所以无需delete，只需置空

	return 0;
}